package com.cykj.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseDTO {
    private Integer code; // 响应状态
    private String msg;   // 响应消息
    private Object data;  // 响应数据


    private static final Integer SUCCESS = 200; // 成功
    private static final Integer ERROR = 404;   // 失败


    // 成功响应
    public static ResponseDTO success(String msg, Object data) {
        return new ResponseDTO(SUCCESS, msg, data);
    }
    // 成功响应
    public static ResponseDTO success(String msg) {
        return new ResponseDTO(SUCCESS, msg, null);
    }

    // 失败响应
    public static ResponseDTO error(String msg) {
        return new ResponseDTO(ERROR, msg, null);
    }
    //
    public static ResponseDTO error(Integer code, String msg) {
        return new ResponseDTO(code, msg, null);
    }
}
